<?php
$menu=array(
	'main'=>array(
			'name'=>'买家首页',
			'action'=>'main',
			'sub'=>array(
				array(
						'name'=>'已买到的商品',
						'type'=>array(1,2),
						'action'=>"?m=product&s=admin_buyorder",
					 ),	
				array(
						'name'=>'我的团购商品',
						'type'=>array(1,2),
						'action'=>'?m=tg&s=admin_tg_order',
					),
				array(
						'name'=>'我的收藏',
						'type'=>array(1,2),
						'action'=>array(
							'?m=sns&s=admin_share_product'=>'收藏商品',
							'?m=sns&s=admin_share_shop'=>'收藏店铺',
							'?m=sns&s=sns'=>'',
							'?m=product&s=admin_receipt'=>'',
							'?m=product&s=admin_orderdetail'=>'',
							'?m=product&s=admin_return'=>'',
							'?m=product&s=admin_return_step'=>'',
							
						)
					),
				array(
						'name'=>'我的积分',
						'type'=>array(1,2),
						'action'=>array(
							'?m=points&s=admin_points'=>'积分明细',
							'?m=points&s=admin_points_order'=>'已兑换的商品',
						)
					),
				array(
						'name'=>'评价管理',
						'type'=>array(1,2),
						'action'=>"?m=shop&s=admin_credit",
					),
				array(
						'name'=>'咨询与维权',
						'type'=>array(1,2),
						'action'=>array(
							'?m=product&s=admin_consult'=>'我的咨询',
							'?m=report&s=admin_myreport'=>'我的举报',
							'?m=report&s=admin_add_report'=>'',
							'msg'=>'',
						)
					)
			),
		),
	'personal'=>array(
			'name'=>'个人中心',
			'action'=>$config['weburl'].'/home.php?uid='.$buid,
		),
	
	'friend'=>array(
			'name'=>'好友',
			'sub'=>array(
						array(
						'name'=>'好友',
						'type'=>array(1,2),
						'action'=>array(
							'?m=sns&s=admin_friends'=>"好友",
						),
					)
			)
	),
	'inquire'=>array(
			'name'=>'站内信',
			'sub'=>array(
						array(
							'name'=>$lang['mes'],
							'type'=>array(1,2),
							'action'=>array(
								'?m=message&s=admin_message_list_inbox'=>$lang['inbox'],
								'?m=message&s=admin_message_list_outbox'=>$lang['outbox'],
								'?m=message&s=admin_message_det'=>'',
								'?m=message&s=admin_message_sed'=>'',
							)
					)
			)
	),
	'user'=>array(
			'name'=>'设置',
			'sub'=>array(
					array(
						'name'=>'个人信息',
						'type'=>array(1,2),
						'action'=>array(
							'?m=member&s=admin_member'=>'个人资料',
							/*'?m=member&s=admin_security'=>'安全设置',*/
							'?m=member&s=admin_orderadder'=>'收货地址',
							'?m=member&s=mail'=>'',
						),
					)
			),	
		),

);

//----------------------
if($_GET['action']=='main' || $_GET['action']=='logout' || ($_GET['action']=='' and  $_GET['m']=='' and $_GET['s']==''))
	$flag='2';
else
	$flag='1';

foreach($menu as $key=>$v)
{
	if(isset($menu[$key]['sub']))
	{
		foreach($menu[$key]['sub'] as $sv)
		{
			if(is_array($sv['action']))
			{
				foreach($sv['action'] as $sskey=>$ssv)
				{
					if($sskey==$_GET['action']||$sskey=='?m='.$_GET['m'].'&s='.$_GET['s'])
					{
						$cmenu=$key;
						$flag='2';
					}	
				}
			}
			else
			{
				if($sv['action']==$_GET['action']||$sv['action']=='?m='.$_GET['m'].'&s='.$_GET['s'])
				{
					$cmenu=$key;
					$flag='2';
				}
			}
		}
		ksort($menu[$key]['sub']);
	}
	if(isset($admin))
	{	
		if($key!='main'&&is_array($menu[$key]['sub']))
		{
			$act=each($menu[$key]['sub']);$subkey=$act['key'];//取出第一个下标
			$act=@each($menu[$key]['sub'][$subkey]['action']);
			$menu[$key]['action']=$act['key'];
		}
	}
}
//----------------------------------------

if($flag=='1')
{
	if($is_company==1)	
	{
		header("Location:main.php?m=shop&s=admin_step");
	}
	else
	{
		if($_GET['cg_u_type'])
		{
			if($_GET['action'])
				header("Location:main.php?cg_u_type=2&action=$_GET[action]");
			elseif($_GET['m'])
				header("Location:main.php?cg_u_type=2&m=$_GET[m]&s=$_GET[s]");
			else
				header("Location:main.php?cg_u_type=2");
		}
		else
		{
			header("Location:main.php?cg_u_type=2");
		}
	}
}
if(isset($tpl))
{
	$cmenu=!empty($cmenu)?$cmenu:'main';
	$smenu=!empty($cmenu)?($cmenu=='friend'||$cmenu=='inquire'?'main':$cmenu):'main';
	$tpl->assign("submenu",$menu[$smenu]);
	$tpl->assign("menu",$menu);
	$tpl->assign("cmenu",$cmenu);
}
?>